#!/bin/bash
set -e

if (($# != 2));then
    echo "Usage   : sh $0 <file_path> <flagNum>"
    echo "For help: sh $0 <file_path> --help"
    exit
fi

# 当前
filePath=$1
flag=$2

# 全局
QUOTA_TEST_PATH="/root/quota_io_test";                export QUOTA_TEST_PATH;
QUOTA_SOURCE_FILE=${QUOTA_TEST_PATH}/0_source_env.sh; export QUOTA_SOURCE_FILE;
QUOTA_CHECK_ENV=${QUOTA_TEST_PATH}/1_check_env.sh;    export QUOTA_CHECK_ENV;
QUOTA_CLEAN_FILE=${QUOTA_TEST_PATH}/2_clean_quota.sh; export QUOTA_CLEAN_FILE;
QUOTA_COMMON_FUNC=${QUOTA_TEST_PATH}/3_common_func.sh;export QUOTA_COMMON_FUNC;

FS_MOUNTPOINT="/mnt/orcafs";                          export FS_MOUNTPOINT;
QUOTA_TEST="test";                                    export QUOTA_TEST;
QUOTA_BASE_DIR="${FS_MOUNTPOINT}/${QUOTA_TEST}";      export QUOTA_BASE_DIR;


function test_file_exist() {
    test_file=$1
    if [ ! -f ${test_file} ]; then
        echo "${test_file} is not exist, exit"
        exit 1
    fi
}

# 检查根目录是否存在
if [ ! -d ${QUOTA_TEST_PATH} ]; then
    echo "${QUOTA_TEST_PATH} is not exist, exit"
    exit 1
fi

# source 公共函数
test_file_exist ${QUOTA_COMMON_FUNC}
source ${QUOTA_COMMON_FUNC}

# 检查配额验证环境
test_file_exist ${QUOTA_CHECK_ENV}
sh ${QUOTA_CHECK_ENV}

# 检查要执行的脚本
test_file_exist ${filePath}
echo "=====检查要执行脚本：${filePath}===== pass"
echo -e "\n"
sh ${filePath} ${flag}


